class Solution:
    def beautifulSubstrings(self, s: str, k: int) -> int:
        vowels = "aeiou"
        n = len(s)
        ans = 0
        for i in range(n):
            cnt = 0
            for j in range(i, -1, -1):
                if s[j] in vowels:
                    cnt += 1
                if cnt == (i - j + 1 - cnt) and cnt * (i - j + 1 - cnt) % k == 0:
                    ans += 1
        return ans
